package com.jh.example;

public class BitNShiftMain2 
{

	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		int intNum1 = 123;
		int intNum2 = -123;
		String s = "1111111111111111111111110000101";
		System.out.println(binTo10("1111011"));
		System.out.println(binTo10(s));
	}

	private static int frBiTo10(String str,int a) 
	{
		int temp = 1;
		int afterParse = Integer.parseInt(str);
		
		temp = a>=1?afterParse<<a:afterParse>>(-a);
		
		
		return temp;
	}
	
	public static int binTo10(String str)
	{
		int nums = 0;
		int count =str.length();
		for (int i = 0; i < count; i++) 
		{
			nums+=frBiTo10(str.charAt(count-1-i)+"", i);
		}
		
		return nums;
	}
	
	

}
